<?php

/*
 * Use : phpstorm
 * 2021/7/21
 * 14:10
 * 订单
 * User: 2650332702@qq.com
 */
namespace App\Api\Controllers;


use App\Api\Manages\CommonController;
use App\Api\Repositories\GroupingRepositorie;
use App\Api\Repositories\OrderListRepositorie;
use App\Api\Repositories\SeckillRepositorie;
use App\Api\Services\JsonService;
use App\Api\Services\Logisticsinterface;
use App\Api\Services\OrderBasic;
use Illuminate\Http\Request;

class OrderListController extends CommonController
{
    //获取用户订单列表
    public function orderList(Request $request)
    {
        $validat = $request->validate([
            'uid' => ['required'],
        ]);
        $orderList = OrderListRepositorie::getAll((int)$validat['uid']);
        if(empty($orderList)){
            return  JsonService::fail('查询数据为空','',config('code.HTTP_NULL_DATA'));
        }else{
            return JsonService::success('查询成功',$orderList,config('code.HTTP_OK'));
        }
    }

    //查看物流
    public function logistics(Request $request)
    {
        $validat = $request->validate([
            'courier' => ['required'],
            'type' => ['required'],
        ]);
        $logistics = Logisticsinterface::logistics($validat['courier'],$validat['type']);
        if($logistics){
            return JsonService::success('查询成功',$logistics,1000);
        }else{
            return  JsonService::fail('查询失败','',1003);
        }
    }


}